package com.liu.susu.thread.task.scheduled.example1;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @FileName TestScheduledTask1
 * @Description
 * @Author susu
 * @date 2022-03-07
 **/

@Component
@Slf4j
public class TestScheduledTask1 {
    private static int count = 0;

    private final static String task1 = "${susu.task.job.corn.task1}";
    private final static String task2 = "${susu.task.job.corn.task2}";

    private final static String fixedDelayString = "${susu.task.fixedDelayTask1}";
    private final static String fixedRateString = "${susu.task.fixedRateTask2}";
//    @Scheduled(cron = "0/5 * * * * ?")
//    @Scheduled(cron = task1)
    @Scheduled(fixedDelayString = fixedDelayString)
    @Async("getSuSuAsyncTaskExecutor2")
    public void doScheduledTask1(){
        log.info("come on!!! doScheduledTask1()--->"+Thread.currentThread().getName());
    }

    //    @Scheduled(cron = task2)
    @Async("getSuSuAsyncTaskExecutor2")
    @Scheduled(fixedRateString = fixedRateString)
    public void doScheduledTask2(){
        log.info("doScheduledTask2()--->"+Thread.currentThread().getName());
    }


}
